package com.example.tianyidemo.service.impl;

import com.example.tianyidemo.Mapper.CommentMapper;
import com.example.tianyidemo.pojo.Comment;
import com.example.tianyidemo.pojo.User;
import com.example.tianyidemo.service.CommentServriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class commentimpl implements CommentServriver {
    private static final Logger logger = LoggerFactory.getLogger(Postimpl.class);
    //  service不能操作数据库，调用mapper接口
    @Autowired
    private CommentMapper commentMapper;
    @Override
    public List<Comment> getcomment() {
      List<Comment> commentList = commentMapper.getComment();
      for (Comment comment : commentList ){
          List<User> users = commentMapper.getCommentID(comment.getCommentsUserID());
          comment.setUserID(users);

      };
        return commentList;
    }
}
